package com.gopay.common.domain.bis;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.gopay.common.cipher.utils.SensitiveInfoUtils;
import com.gopay.common.domain.BaseEntity;

/**
 * 签约信息流水表
 * 
 * @BisBankContractSerialInfo.java
 * @author zhengxue
 * @2016-12-14 下午2:38:00 www.gopay.com.cn Inc.All rights reserved.
 */
@Entity
@Table(name = "BIS_BANK_CONTRACT_SERIAL_INFO")
public class BisBankContractSerialInfo extends BaseEntity {


    private static final long serialVersionUID = 1718922395460558503L;

    /**
     * 流水号
     */
    private int id;

    /**
     * 银行代码
     */
    private String bankCode;

    /**
     * 银行业务产品代码
     */
    private String bankBizProdCode;

    /**
     * 接口通道代码
     */
    private String intrfaceChannelCode;

    /**
     * 卡号
     */
    private String cardNo;
    
    /**
     * 要素加密值
     */
    private String elementsValue;

    /**
     * 签约码
     */
    private String contractNumber;

    /**
     * 流水号
     */
    private String serialNumber;

    /**
     * 签约状态 01：已签约（如果用户已解约或签约过期导致签约失败则修改为 02:签约作废，下次需重新发起签约）
     */
    private String contractState;

    /**
     * 签约描述 （记录签约失败的原因）
     */
    private String contractDesc;

    /**
     * 创建时间
     */
    private Date createdTs;

    /**
     * 最后修改时间
     */
    private Date lastUpdTs;

    @Id
    @Column(name = "ID", nullable = false)
    @SequenceGenerator(name = "BIS_BANK_CONTRACT_SERIAL_SQ_GENERATOR", sequenceName = "BIS_BANK_CONTRACT_SERIAL_SEQ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BIS_BANK_CONTRACT_SERIAL_SQ_GENERATOR")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "BANK_CODE", nullable = false)
    public String getBankCode() {
        return bankCode;
    }

    public void setBankCode(String bankCode) {
        this.bankCode = bankCode;
    }

    @Column(name = "BANK_BIZ_PROD_CODE", nullable = false)
    public String getBankBizProdCode() {
        return bankBizProdCode;
    }

    public void setBankBizProdCode(String bankBizProdCode) {
        this.bankBizProdCode = bankBizProdCode;
    }

    @Column(name = "INTRFACE_CHANNEL_CODE", nullable = false)
    public String getIntrfaceChannelCode() {
        return intrfaceChannelCode;
    }

    public void setIntrfaceChannelCode(String intrfaceChannelCode) {
        this.intrfaceChannelCode = intrfaceChannelCode;
    }

    @Column(name = "CARD_NO")
    public String getCardNo() {
        /**
         * modify by hougn，2017-04-17在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
         */
        this.cardNo = SensitiveInfoUtils.autoReencrypt(this.cardNo);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.cardNo);
    }

    public void setCardNo(String cardNo) {
        /**
         * modified by hougn，2017-04-17 判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
         */
        this.cardNo = SensitiveInfoUtils.smartEncryptWithCheck(cardNo);
    }

    @Column(name = "CONTRACT_NUMBER")
    public String getContractNumber() {
        return contractNumber;
    }

    public void setContractNumber(String contractNumber) {
        this.contractNumber = contractNumber;
    }

    @Column(name = "SERIAL_NUMBER")
    public String getSerialNumber() {
        return serialNumber;
    }

    public void setSerialNumber(String serialNumber) {
        this.serialNumber = serialNumber;
    }

    @Column(name = "CONTRACT_STATE")
    public String getContractState() {
        return contractState;
    }

    public void setContractState(String contractState) {
        this.contractState = contractState;
    }

    @Column(name = "CONTRACT_DESC")
    public String getContractDesc() {
        return contractDesc;
    }

    public void setContractDesc(String contractDesc) {
        this.contractDesc = contractDesc;
    }

    @Column(name = "CREATED_TS")
    public Date getCreatedTs() {
        return createdTs;
    }

    public void setCreatedTs(Date createdTs) {
        this.createdTs = createdTs;
    }

    @Column(name = "LAST_UPD_TS")
    public Date getLastUpdTs() {
        return lastUpdTs;
    }

    public void setLastUpdTs(Date lastUpdTs) {
        this.lastUpdTs = lastUpdTs;
    }

    @Column(name ="ELEMENTS_VALUE", nullable= false)
    public String getElementsValue() {
        return elementsValue;
    }

    public void setElementsValue(String elementsValue) {
        this.elementsValue = elementsValue;
    }

}
